package reflect;

import java.util.ArrayList;
import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws Exception {
        /*ArrayList list = new ArrayList();
        System.out.println(list);*/

        //Class cls = Class.forName("java.util.ArrayList");

        /*Scanner scanner = new Scanner(System.in);//反射机制可以运行起来根据需要实例化对象
        System.out.println("请输入一个类");
        String className = scanner.nextLine();
        Class cls = Class.forName(className);
        Object obj = cls.newInstance();
        System.out.println(obj);*/
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个类");
        Class cls = Class.forName(scanner.nextLine());
        Object obj = cls.newInstance();
        System.out.println(obj);
    }
}
